home *** CD-ROM | disk | FTP | other *** search
/ Precision Software Appli…tions Silver Collection 4 / Precision Software Applications Silver Collection Volume 4 (1993).iso / stats / chadyn.exe / YMAPMENU.C < prev    next >
Text File  |  1988-12-15  |  11KB  |  487 lines

  1. /************************* YMapMenu.C ************************/
  2. /********************* (C) 1986,7,8 by JAMES A. YORKE ************************/
  3.  
  4. #include "yinclud.h"
  5. /* ************************** routines in file:
  6. map_menu(output,map)  for select_map() /
  7.     FILE *output;
  8.     char *map;
  9. d_mod()
  10. v_mod()
  11. p_mod()
  12. v2_mod()
  13. y_mod_for_des()
  14. init_map(output)
  15.     FILE *output;
  16.      This routine should occur after the maps are defined or 
  17.     the maps should be declared. Notice the declaration of the
  18.     differential equations 
  19. ****************************/
  20. #ifdef YYFILE
  21. char otherText[80] = "\r";
  22. #endif
  23.  
  24.  
  25.  
  26. map_menu(output,map) /* for select_map() */
  27.     FILE *output;
  28.     char *map;
  29. {
  30.     /*  if  output = stdprn, program would send the list to the printer */
  31.     if(strcmp(map,"all") == 0)
  32.           get_set(output,map);
  33.  
  34.  
  35. /*     Written by JIM YORKE,(c)1985,6,7,8  Copy freely, but do not sell.\n");*/
  36.     if (strcmp(map,"all") == 0) 
  37.                 fputs("\n",output);
  38.  
  39.     if (strcmp(map,"all") == 0) 
  40.         fputs(
  41. "C   Cubic map in complex plane  \n"
  42.         ,output);
  43.     TESTMAP("c")
  44.         fputs(
  45. "C   Cubic in complex plane  rho*Z^3 + (C1+iC2)*Z^2 + (C3+iC4)*Z + C5+iC6\n"
  46.         ,output);
  47.     TESTMAP("c")
  48.                  fputs("Z = X + iY; set rho = 0 for quadratic polynomial\n"
  49.             ,output);
  50.  
  51.  
  52.  
  53.  
  54.     if (strcmp(map,"all") == 0) 
  55.         fputs(
  56. "DR  Double Rotor: A 4-dim map    \n"
  57.             ,output);
  58.     TESTMAP("dr")
  59.         fputs(
  60. "DR  Double Rotor: A 4-dim map: 2 linked rods with impulse strength rho    \n"
  61.             ,output);
  62.  
  63.     TESTMAP("dr")
  64.         {    fputs(
  65. "mass1,2=C1,2;length2=C4;length1=C4*sqrt(C2/ C1+C2);damping1,2=C5,6 hittime=C7"
  66.             ,output);
  67.         fputs("\n",output);
  68.     }
  69.  
  70.  
  71.     if (strcmp(map,"all") == 0) 
  72.         fputs(
  73. "DDR Degenerate Double Rotor \n"
  74.         ,output);
  75.     TESTMAP("ddr")
  76.         fputs(
  77. "DDR Degenerate Double Rotor: like DR  except wait until it stops each time\n"
  78.         ,output);
  79.     TESTMAP("ddr")
  80.         {    fputs(
  81. "mass1,2=C1,2;length2=C4;length1=C4*sqrt(C2/ C1+C2);damping1,2=C5,6 \n"
  82.         ,output);
  83.     }
  84.  
  85.  
  86.     if (strcmp(map,"all") == 0) 
  87.         fputs(
  88. "H   The Henon map                           \n"
  89. ,output    );
  90.     TESTMAP("h")
  91.         fputs(
  92. "H   The Henon map: (x,y) -> (rho -x*x +C1*y, x)                           \n"
  93. ,output    );
  94.  
  95.  
  96.     if (strcmp(map,"all") == 0) 
  97.         fputs(
  98. "I   Ikeda Laser map\n"
  99.         ,output);
  100.     TESTMAP("i")
  101.         fputs(
  102. "I   Ikeda Laser map:(Z = x+iy) Z -> rho +C2*Z*exp{i[C1 - C3/(1 + |Z|^2)]}\n"
  103.         ,output);
  104.     TESTMAP("i")
  105.                 fputs(
  106. "     tau = C1 - C3/(1+x*x+y*y); x -> rho + C2*[x*cos(tau) -y*sin(tau)]     \n"
  107.     ,output);
  108.     TESTMAP("i")
  109.                   fputs(
  110. "                                y ->       C2*[x*sin(tau) +y*cos(tau)]\n"
  111.         ,output);
  112.  
  113.  
  114.     if (strcmp(map,"all") == 0) 
  115.         fputs(
  116. "Q   Quasiperiodicity map \n"
  117.         ,output);
  118.     TESTMAP("q")
  119.         fputs(
  120. "Q   Quasiperiodicity vs Chaos See Grebogi-Ott-Yorke Physica 15D 1985 p.354\n"
  121.         ,output);
  122.     TESTMAP("q"){
  123.         fputs(
  124. "        X -> X + C1 + rho*P1,    Y ->Y + C2 + rho*P2  both mod 1    \n"
  125.         ,output);
  126.         fputs(
  127. "  P1 and P2 are each period 1 in X and Y. Map is invertible for rho < 0.673\n"
  128.         ,output);
  129.     }
  130.  
  131.  
  132.     if (strcmp(map,"all") == 0) 
  133.         fputs(
  134. "R   Pulsed Rotor and standard map\n"
  135.         ,output);
  136.     TESTMAP("r")
  137.         fputs(
  138. "R   Pulsed Rotor:  x -> x + y  mod(2 pi) + pi THEN  y -> C1*y + rho*sin(x)\n"
  139.         ,output);
  140.  
  141.  
  142.     if (strcmp(map,"all") == 0) 
  143.         fputs(
  144. "RR  Random Rotate map \n"
  145.         ,output);
  146.     TESTMAP("rr")
  147.         fputs(
  148. "RR  at Random either Rotate by C1 degrees and mult by rho OR flip about 1,0\n"
  149.         ,output);
  150.     TESTMAP("rr")
  151.     {
  152.                  fputs(
  153. "    The probability of a flip (x -> 2-x, y-> -y) is C2\n"
  154.             ,output);
  155.                  fputs(
  156. "    Otherwise rotate C1 degrees about 0,0 and multiply x and y by rho (<1)\n"
  157.             ,output);
  158.     }
  159.  
  160.  
  161.  
  162.     if (strcmp(map,"all") == 0) 
  163.         fputs(
  164. "T   Tinkerbell:",output);
  165.     TESTMAP("t"){
  166.         fputs(
  167. "T   Tinkerbell:",output);
  168.         fputs(
  169. " x(n+1) = x*x-y*y + C1*x +C2*y; y(n+1) = 2*x*y + C3*x +C4*y\n",output);
  170.         }
  171.  
  172. #ifdef DONTPRINT
  173. #ifdef MS
  174.     TESTMAP2("testh")
  175.         fputs(
  176. "TESTH (experimental)   The Henon map: (x,y) -> (rho -x*x +C1*y, x)         \n"
  177. ,output    );
  178. #endif
  179. #endif /* DONTPRINT */
  180.  
  181.     /* space break between maps and dif eqns */
  182.     if (strcmp(map,"all") == 0) 
  183.                 fputs("\n",output);
  184.  
  185.  
  186.     if (strcmp(map,"all") == 0) 
  187.         fputs(
  188. "D   Forced Double Well Duffing equation\n"
  189.         ,output);
  190.     TESTMAP("d")
  191.         fputs(
  192. "D   Forced Double Well Duffing  x'' +C1*x' -C2*x +C3*x^3 = rho*sin(C4*t)\n"
  193.         ,output);
  194.     TESTMAP("d")
  195.         fputs(
  196. "Numbering of variables: y[0]= time mod twopi/C4 ,y[1]=x, y[2]=x', y[3]=t   \n"
  197.         ,output);
  198.  
  199.  
  200.     if (strcmp(map,"all") == 0) 
  201.         fputs(
  202. "L   The Lorenz system \n"
  203.         ,output);
  204.     TESTMAP("l")
  205.         fputs(
  206. "L   The Lorenz system: x'= sigma*(y-x), y'= rho*x -y -x*z, z'= x*y- beta*z\n"
  207.         ,output);
  208.     TESTMAP("l")
  209.         fputs(
  210. "Numbering of variables: y[0]=x ,y[1]=y, y[2]=z, y[3]=time                  \n"
  211.         ,output);
  212.  
  213.  
  214.     if (strcmp(map,"all") == 0) 
  215.         fputs(
  216. "LPR The Lorenz system's Poincare Return map \n"
  217.         ,output);
  218.     TESTMAP("lpr")
  219.         fputs(
  220. "LPR The Lorenz system: Poincare Return map using plane z = rho - 1        \n"
  221.         ,output);
  222.     TESTMAP("lpr")
  223.         fputs(
  224. "A dot is plotted in x-y plane when trajectory crosses downward past z=rho-1\n"
  225.         ,output);
  226.  
  227.  
  228.     if (strcmp(map,"all") == 0) 
  229.         fputs(
  230. "P   Forced Damped Pendulum \n"
  231.             ,output);
  232.     TESTMAP("p")
  233.         fputs(
  234. "P   Forced Damped Pendulum x''+C1*x' +C2*sin x =rho*(C3+cos(C4*t))        \n"
  235.             ,output);
  236.     TESTMAP("p")
  237.         fputs(
  238. "Numbering of variables: y[0]= time mod twopi/C4 ,y[1]=x, y[2]=x', y[3]=t   \n"
  239.             ,output);
  240.  
  241.     if (strcmp(map,"all") == 0) 
  242.         fputs(
  243. "SAM N.Samardzija/L.Geller odd symmetry Lorenz-like system \n"
  244.             ,output);
  245.     TESTMAP("sam")
  246.         fputs(
  247. "SAM N.Samardzija/L.Geller: x'= C1*x+C2*y-z, y'= C3*x+C5*y-C6*x^3, z'= rho*x\n"
  248.             ,output);
  249.     TESTMAP("sam")
  250.         fputs(
  251. "Numbering of variables: y[0]=x ,y[1]=y, y[2]=z, y[3]=time                  \n"
  252.             ,output);
  253.  
  254.     if (strcmp(map,"all") == 0) 
  255.         fputs(
  256. "V   forced Van der Pol equation  \n"
  257.             ,output);
  258.     TESTMAP("v")
  259.         fputs(
  260. "V   Van der Pol  x''- C1*x'*(1-x*x) +C2*x +C3*x^3 =rho*sin(C4*t)         \n"
  261.             ,output);
  262.  
  263.  
  264.     if (strcmp(map,"all") == 0) 
  265.         fputs(
  266. "V2  2 forced coupled Van der Pol equations \n"
  267.             ,output);
  268.     TESTMAP("v2")
  269.         fputs(
  270. "V2  2 VdPs:  x1''- C1*x1'*(1-x1*x1) +C2*x1 +C3*x1^3 =rho*{sin(C4*t) +x2} \n"
  271.             ,output);
  272.     TESTMAP("v2")
  273.         fputs(
  274. "             x2''- C5*x2'*(1-x2*x2) +C6*x2 +C7*x2^3 =rho*{sin(C4*t) +x1} \n"
  275.             ,output);
  276.     TESTMAP("v2")
  277.         fputs(
  278. "Variables: y[0]= time mod twopi/C4 ,y[1]=x1, y[2]=x1', y[3]=x2, y[4]=x2'   \n"
  279.             ,output);
  280.  
  281.  
  282. #ifdef DONTPRINT
  283. #ifdef MS
  284.     TESTMAP2("testp")
  285.         fputs(
  286. "TESTP is a pendulum;Variables: y[0]= time mod twopi,y1 is in -pi,pi  \n"
  287.             ,output);
  288. #endif /* DONTPRINT */
  289.  
  290. #ifdef TESTING /* not yet for public consumption */
  291.     TESTMAP2("other")
  292.         fputs(
  293. "OTHER is for previously prepared files of reverse Polish notation commands\n"
  294.             ,output);
  295.     TESTMAP("other")
  296.         fputs( otherText, output);
  297. #endif /* TESTING */
  298.  
  299. #endif    
  300.     if (strcmp(map,"all") == 0) 
  301.                 fputs(
  302. "other differential equations    PD: (Parametric Duffing) \n"
  303.             ,output);
  304.  
  305.     TESTMAP("pd")
  306.     {    
  307.         fputs(
  308. "PD PARAMETRICALLY DRIVEN DUFFING: \n"
  309.             ,output);
  310.         fputs(
  311. "      x'' +C1*x' -x +C2*(1+rho*sin(C4*t))*x^2 +C3*(1+rho*sin(C4*t))*x^3 = 0\n"
  312.             ,output);
  313.      }
  314.  
  315.     if (strcmp(map,"all") == 0) 
  316.               fputs(
  317. "XX   to terminate program                                        \n"
  318.         ,output);
  319. }
  320.  
  321.  
  322.  
  323. /*    y[0] = moduloAB(y[0],0.,1.);
  324.     y[1] = moduloAB(y[1],0.,1.);
  325. */
  326.  
  327. init_map(output)
  328.     FILE *output;
  329.  
  330.     /* This routine should occur after the maps are defined or 
  331.     the maps should be declared. Notice the declaration of the
  332.     differential equations */
  333. {
  334. #ifdef YYFILE
  335.     int initOther();
  336. #endif
  337.     int GetMapName();
  338.     /* the following do not have to be declared if they are defined
  339.         in this file above the spot where it is called */
  340.     char *gets();/* gets obtains a line-edited string from the console and 
  341.         puts it into the beffer that is its argument: gets(buf);
  342.         it returns its argument or 0 on end of file or on error; */
  343.  
  344.     strcpy(MapName,"-9999");/*this is default for detecting bad input*/
  345.  
  346.    while(strcmp(MapName,"-9999") ==0)/* go thru this routine until a legal
  347.             map is typed and a break occurs */
  348.    {
  349.     if (input == StInput)
  350.         map_menu(output,"all");/* this just prints info on the screen*/
  351.  
  352.     if (GetMapName() <= 0)/* means the name is not acceptable */ 
  353.     {
  354.         strcpy(MapName,"-9999");/* this re-initializes to the 
  355.             default for detecting bad input */
  356.         continue;
  357.     }
  358.  
  359.      TESTMAP("a")
  360.     {
  361.         init_aron();
  362.         continue; /* causes exit from switch */
  363.     }
  364.      TESTMAP("rr")
  365.     {
  366.         init_bob();
  367.         continue; /* causes exit from switch */
  368.     }
  369.     TESTMAP("c")/* cubic */
  370.     {
  371.         initcubic();
  372.         continue; /* causes exit from switch */
  373.     }
  374.      TESTMAP("h")
  375.     {
  376.         initHenon();
  377.         continue; /* causes exit from switch */
  378.     }
  379.     TESTMAP("q")
  380.     {        /* Ruelle-Takens torus map  */
  381.         initRuelleTakens();
  382.         continue; /* causes exit from switch */
  383.     }
  384.     TESTMAP("t")
  385.     {
  386.         initComplex();
  387.         continue; /* causes exit from switch */
  388.     }
  389.     TESTMAP("r")
  390.     {            
  391.         initRotor();
  392.         continue; /* causes exit from switch */
  393.     }
  394.     TESTMAP("dr")
  395.     {    /* double rotor in YDblRtr.C */
  396.         initDblRotor();
  397.         continue; /* causes exit from switch */
  398.     }
  399.     TESTMAP("ddr")
  400.     {    /* Degenerate double rotor in YDegen.C */
  401.         initDegenerateDblRotor();
  402.         continue; /* causes exit from switch */
  403.     }
  404.     TESTMAP("i")/* Ikeda */
  405.     {
  406.         initLaser();
  407.         continue; /* causes exit from switch */
  408.     }
  409.     TESTMAP("l")
  410.     {
  411.         initLorenz();
  412.         continue;
  413.     }
  414.     TESTMAP("lpr")
  415.     {
  416.         initLRetMap();
  417.         continue;
  418.     }
  419.     TESTMAP("sam")
  420.     {
  421.         initSam();
  422.         continue;
  423.     }
  424.     TESTMAP("d")/* Duffing */
  425.     {       /* x'' + C1*x' -C2*x +C3*x^3 = rho*sin(C4*t) */ 
  426.         initDED();
  427.         continue; /* causes exit from switch */
  428.     }
  429.     TESTMAP("p")
  430.     {
  431.         initDEP();
  432.         continue; /* causes exit from switch */
  433.     }
  434.     TESTMAP("pd")/* Parametric Duffing */
  435.     {       
  436.         initDEPD();
  437.         continue; /* causes exit from switch */
  438.     }
  439.     TESTMAP("v")
  440.     {
  441.         initDEV();
  442.         continue; /* causes exit from switch */
  443.     }
  444.     TESTMAP("v2")
  445.     {
  446.         initDblVanderpol();
  447.         continue; /* causes exit from switch */
  448.     }
  449. #ifdef YYFILE
  450.      TESTMAP("testh")
  451.     {
  452.         initTestH();
  453.         continue; /* causes exit from switch */
  454.     }
  455.     TESTMAP("testp")
  456.     {
  457.         initTestP();
  458.         /* modPointer is specified in initTestP() */
  459.         continue; /* causes exit from switch */
  460.     }
  461.     TESTMAP("other")
  462.     {
  463.         if (initOther() == YES)        /* this routine in YY.C 
  464.                 asks for a file name and tries to open it; 
  465.                 if the file can be opened, it returns YES */
  466.             continue; /* causes exit from switch */
  467.     }
  468. #endif
  469.     TESTMAP("xx")
  470.     {
  471.         level = KILL;
  472.         character_mode();
  473.         exit(0);
  474.         continue;
  475.     }
  476.     PRINT
  477.     "That was NOT a proper response buster; try again.  To exit: XX \n");
  478.     strcpy(MapName,"-9999");/* this is 
  479.             default for detecting bad input */
  480.     continue;
  481.    } /* while end */
  482. }
  483.  
  484.  
  485.  
  486.  
  487.